﻿using System;

namespace FunctionalCLR.Core.Functions.Maths {

    /// <summary>
    /// roundedPI=round(3.1415926, 2);
    /// echo(roundedPI);
    /// 
    /// The result is 
    /// 3.14
    /// </summary>
    public class RoundNode : FuncNode {

        public RoundNode()
            : base() {
            base.Value = "round";
            this.ParameterCount = 1;
        }

        public override object Evaluate() {
            double result = Convert.ToDouble(
                Children[0].Evaluate());

            return Math.Round(result).ToString();
        }
    }
}
